import React from 'react';
import Loadable from 'react-loadable';

import './WeaNonStandard.less';

const loadable = (loader, loading = () => null) => Loadable({ loader, loading });
const WeaNonStandard = loadable(() => import('./WeaNonStandard'));

class Index extends React.Component {
  constructor(props) {
    super(props);
    const { location = {}, visible = false } = props;
    const { query = {} } = location;
    const { display = '' } = query;
    this.state = { display, visible };
  }

  render() {
    const { display, visible } = this.state;
    return display == 'page' || visible ? <WeaNonStandard ecId={`${this && this.props && this.props.ecId || ''}_WeaNonStandard@o84oif`} {...this.props} display={display} visible={visible} onShow={this.onShow} /> : null;
  }

  onShow = (visible = true) => {
    this.setState({ visible });
  };

  onHide = () => {
    this.setState({ visible: false });
  };
}

export default Index;
